package com.whvc;

public class PrimitiveTypeDemo {
    public static void main(String[] args) {
        byte byteNum = 127;
        short shortNum = 32767;
        int intNum = 2147483647;
        long longNum = 9223372036854775807L;

        float floatNum = 3.14159f;
        double doubleNum = 3.141592653589793;

        char char1 = 'A';
        char char2 = '中';
        char char3 = 65;

        boolean isTrue = true;
        boolean isFalse = false;

        System.out.println("===== 整数类型 =====");
        System.out.println("byte类型: " + byteNum);
        System.out.println("short类型: " + shortNum);
        System.out.println("int类型: " + intNum);
        System.out.println("long类型: " + longNum);

        System.out.println("\n===== 浮点类型 =====");
        System.out.println("float类型: " + floatNum);
        System.out.println("double类型: " + doubleNum);

        System.out.println("\n===== 字符类型 =====");
        System.out.println("char1: " + char1 + " (ASCII值: " + (int) char1 + ")");
        System.out.println("char2: " + char2 + " (Unicode值: " + (int) char2 + ")");
        System.out.println("char3: " + char3 + " (由ASCII码65转换)");

        System.out.println("\n===== 布尔类型 =====");
        System.out.println("isTrue: " + isTrue);
        System.out.println("isFalse: " + isFalse);

        System.out.println("\n====类型示例转换====");
        int num1 = 100;
        long num2 = num1;
        System.out.println("int转long: " + num2);

        long num3 = 200;
        int num4 = (int) num3;
        System.out.println("long转int: " + num4);

        System.out.println("\n====溢出示例====");
        byte overflowByte = (byte) 128;
        System.out.println("byte溢出结果：" + overflowByte);
    }
}
